<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>AFC设备维修系统-角色信息列表</title>
		<link rel="stylesheet" type="text/css"
			href="<%=request.getContextPath()%>/css/common.css" />
		<link rel="stylesheet" type="text/css"
			href="<%=request.getContextPath()%>/css/tag.css" />
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/jquery-1.7.2.js">
		</script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/My97DatePicker/WdatePicker.js">
		</script>
	</head>

	<body>
	<jsp:include page="/jsp/common/top.jsp"></jsp:include>
		<!-- 顶部start -->
		<div id="main">
			<div class="body">
				<!-- 导航菜单 -->
				<jsp:include page="/jsp/common/nav.jsp"></jsp:include>
				
				<!-- 主体 -->
				<div class="main_body">
					<form action="getRoleList.action" method="post" onsubmit="return checkFindFrm();">
						<table class="condition bg1"
							style="width: 100%; font-size: 14px; font-weight: bold; color: #000000;"
							align="center">
							<tr>
								<td width="20%" style="height: 40px;" align="right">
									<label>
										角色编号：
									</label>
									<input name="role.rolecode" type="text" class="text" value="${role.rolecode }" id="code"/>
								</td>
								<td width="20%" style="height: 40px;" align="center">
									<label>
										角色名称：
									</label>
									<input name="role.rolename" type="text" class="text" value="${role.rolename }" id="name"/>
								</td>
								<td width="40%" style="height: 40px; text-align: left;">
									<input name="button" type="submit" class="btn-title" value="搜索" />
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<input name="button" id="button2" type="button" class="btn-title" value="重置" />
								</td>
								<td width="8%" style="height: 40px; text-align: right;">
									<input  type="button" class="btn-title" value="新增"
										onclick="window.location.href='toRoleAdd.action'" />
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								</td>
							</tr>
						</table><input type="hidden" name="currentPage" id="currentPage" />
					</form>
						<div id="list_div">
							<table class="table_list" width="100%">
								<tr class="bg">
									<th width="30%">
										角色编号
									</th>
									<th width="45%">
										角色名称
									</th>
									
									<th>
										操作
									</th>
								</tr>
								<s:iterator value="roleLists" id="clist">
									<tr>
										<td title="${clist.rolecode}">
											${fn:substring(clist.rolecode, 0, 20) }
										</td>
										<td title="${clist.rolename}">
											<a href="roleDetail?role.id=${clist.id }&role.rolecode=${clist.rolecode}" class="underline"> ${fn:substring(clist.rolename, 0, 20) }</a>
										</td>
									
										<td>
											<a href="toRoleEdit.action?role.id=${clist.id }" title="编辑"> <img
													src="<%=request.getContextPath()%>/images/modify.gif"
													alt="编辑" align="absmiddle" /> </a>
											<a href="roleDetail?role.id=${clist.id }&role.rolecode=${clist.rolecode}" title="详情"> <img
													src="<%=request.getContextPath()%>/images/detail.gif"
													alt="详情" align="absmiddle" /> </a>
											<a href="#" onclick="del('${clist.rolecode}');" title="删除"> <img
													src="<%=request.getContextPath()%>/images/delete.gif"
													alt="删除" align="absmiddle" /> </a>
										</td>
									</tr>
								</s:iterator>
							</table>
							<!-- 分页 -->
							<jsp:include page="/jsp/common/page.jsp"></jsp:include>
						</div>
					
				</div>
			</div>
			<!-- 顶部end -->

		<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
		</div>
		<script type="text/javascript">
			//设置高亮
			$(function(){
		        //selectNav('nav2');
		    });
		    
			$('#button2').click(function(){	
				$('#name').val('');
				$('#code').val('');
			});
			
			//分页事件
			function pageSub(currentPage) {
				var reg=/^\d*?$/;
				var total =${page.totalPages};
			 	if(reg.test(currentPage)){
				 	if(currentPage > total){
				 		$("#currentPage").val(total);
				 	}else{
				 		$("#currentPage").val(currentPage);
				 	}
				 	document.forms[0].submit();
				}else{
					  alert("请输入数字!"); 
				}
			}
			
			//删除
			function del(accountid){
				if(confirm('确定删除该条记录？')){
					$.ajax({
				        url: 'delete.action?role.rolecode='+ accountid,
				        type:"POST",
				        cache:false,
				        success: function(message){
					    	if(message == "success"){
				        		alert("删除成功！");
				        		window.location.href="getRoleList.action";
				        	}else if(message=="exist"){
				        		alert("当前角色正在使用,暂不能删除！");
				        	}else if(message=="error"){
								window.location.href="goError.action";
							}else{
					    		alert('删除失败！');
				        	}
				   		}
			     	});
				}
			}
	
			//验证条件
			function checkFindFrm(){
				var myReg = /^[^@\/\'\\\"#$%&\^\*<>]+$/;
				var name =$('#name').val();
				var account =$('#code').val();
				if(null !=name && name!=''){
					if (!myReg.test(name)) {
						alert("查询条件不能含有$、#、%、/、*、<、>、'、\"、\\、&等特殊字符，请重新输入！");
						$('#name').focus();
						return false;
					}
				}
				if(null !=account && account !=''){
					if (!myReg.test(account)) {
						alert("查询条件不能含有$、#、%、/、*、<、>、'、\"、\\、&等特殊字符，请重新输入！");
						$('#code').focus();
						return false;
					}
				}
				//重置内容
				$('#name').val($.trim(name));
				$('#code').val($.trim(account));
			}				
		</script>
	</body>
</html>
